% 计算给定正弦输入信号的功率，根据snr添加高斯白噪声
clear all;
t=0:0.001:10;
x=sin(2*pi*t);
snr=20;
y=awgn(x, snr,'measured');
subplot(2,1,1);plot(t,x);title('正弦信号x');
subplot(2,1,2);plot(t,y);title('叠加了高斯白噪声后的正弦信号');